<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:v-popover="http://www.w3.org/1999/xhtml" class="height_100">
<head>
    <meta charset="UTF-8">
    <title>睿云 让生活更美好！</title>
</head>
<link rel="stylesheet" href="../static/css/element.css" th:href="@{/css/element.css}">
<link rel="stylesheet" href="../static/css/global.css" th:href="@{/css/global.css}"/>
<link rel="stylesheet" href="../static/css/main.css" th:href="@{/css/main.css}"/>
<link rel="stylesheet" href="../static/css/myelement.css" th:href="@{/css/myelement.css}"/>

<!-- 引入组件库 -->
<script src="../static/js/vue.js" th:src="@{/js/vue.js}"></script>
<script src="../static/js/element.js" th:src="@{/js/element.js}"></script>
<script src="../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
<script src="../static/js/mainframe.js" th:src="@{/js/mainframe.js}"></script>
<body class="height_100">

<!--头部-->
<div id="app" v-cloak class="height_100" :class="{'menu_ico':menuIco,'aside_hide':asideHide,'aside_none':asideNone}">
    <div class="topBar">
    	<div class="logo">
	        <img src="../static/img/logo.png" th:src="@{/img/logo.png}" alt=""/>
		</div>
		<div class="logo2">
	        <img src="../static/img/logo_2.png" th:src="@{/img/logo_2.png}" alt=""/>
	    </div>
        <div class="nav-tab" id="main_menu">
            <ul class="clearfix">
            </ul>
        </div>
        <div class="wrap-header-right-menu">
            <el-popover ref="popover2" placement="top-start" width="120" trigger="hover">
                <ol class="z-pop-top">
                    <li><a href="javascript:iframeReload()">刷新当前页面</a></li>
                    <!-- 
                    <li><a href="javascript:iframeClose()">关闭当前页面</a></li>
                    <li><a href="javascript:iframeCloseAll()">关闭全部页面</a></li>
                     -->
                </ol>
            </el-popover>
            <a href="javascript:;" v-popover:popover2><img src="../static/img/reflesh.png" th:src="@{/img/reflesh.png}" alt=""/></i></a>

            <!-- 
            <el-popover ref="popover3" placement="top-start" width="120" trigger="hover">
                <ol class="z-pop-top">
                    <li><a href="javascript:;">订单留言 (<span>0</span>)</a></li>
                    <li><a href="javascript:;">留言咨询 (<span>0</span>)</a></li>
                    <li><a href="javascript:;">站内信</a></li>
                </ol>
            </el-popover>
            <a href="javascript:;" v-popover:popover3><img src="../static/img/megs.png" th:src="@{/img/megs.png}" alt=""/></a>
            -->
            <el-popover ref="popover4" placement="top-start" width="120" trigger="hover">
                <ol class="z-pop-top">
                    <li><a @click="showDailog"	>修改密码</a></li>
                    <li><a href="/logout">退出</a></li>
                </ol>
            </el-popover>
            <a href="javascript:;" class="z-wo" v-popover:popover4><img src="../static/img/mine.png" th:src="@{/img/mine.png}" alt=""/><span>{{manager.loginName}}</span></a>

        </div>
    </div>

	<!--修改密码-->
	<el-dialog title="修改密码" :visible.sync="dialogFormVisible">
		<el-form ref="rules-form" :model="ruleform"  label-width="80px" size="small">
			<el-form-item label="旧密码">
				<el-input type="password" v-model="ruleform.oldPwd" ></el-input>
			</el-form-item>
			<el-form-item label="新密码">
				<el-input type="password" v-model="ruleform.pwd" ></el-input>
			</el-form-item>
			<el-form-item label="确认新密码">
				<el-input type="password" v-model="ruleform.confirmPwd" ></el-input>
			</el-form-item>
			<el-form-item label="">
				<div class="m-remind">
					<div class="m-prompt" v-show="logining" v-cloak>
						<span><s></s>{{rules2.message}}</span>
					</div>
				</div>
			</el-form-item>
		</el-form>
		<div slot="footer" class="dialog-footer">
			<el-button @click="updatePassword" type="primary">确定</el-button>
			<el-button @click="dislogHide">取消</el-button>
		</div>
	</el-dialog>


	<!--左侧-->
	<div class="leftBar">
	    <div class="aside-wrap">
	        <div class="menu_toggle" @click="menuIcoTg"><s></s></div>
	        <ul>
	        	<li class="navi-item" v-for="(item,index) in menuData" :class="{'active':menuOneCur==index}" :key="index">
					<a href="javascript:void(0)" @click="menuGo(item,index)">
						<i><img :src="'/img/'+item.ico"/></i>
						<span class="nav-item-title">{{item.title}}</span>
					</a>
					<span class="nav-tip">{{item.title}}</span>
				</li>
	        </ul>
	    </div>
	    <div class="aside-menu">
	    	<div class="aside_toggle" @click="asideTg"></div>
			<div class="menu_item" v-for="(item,index) in menuData" v-show="menuOneCur==index" :key="index">
				<h2 class="menu_title">
					<img :src="'/img/'+item.ico2"/>
					<span class="nav-item-title">{{item.title}}</span>
				</h2>
				<ul>
					<li v-for="(sub,size) in item.children" :class="{'active':menuTwoCur==size}">
						<a href="javascript:void(0)" @click="pageGo(sub.page,size)">{{sub.title}}</a>
					</li>
				</ul>
			</div>
	    </div>
	</div>


	<!--主体-->
	<div id="main_iframe">
	    <div class="tab-pane active" data-id="menu_0" id="defaultFrame">
	        <iframe :src="mainUrl" width="100%" height="100%" frameborder='0' name="menuFrame" id="menuFrame"></iframe>
	    </div>
	</div>
</div>
</body>
<script th:inline="javascript">
    new Vue({
        el: "#app",
        data: {
        	manager:[[${manager}]],
            logining: false,
            dialogFormVisible: false,
            ruleform: {
                oldPwd: '',
                pwd: '',
                confirmPwd: ''
            },
            rules2:{
                message:'',
            },
        	menuIco: false,  // 一级菜单是否只展示图标
        	asideHide: false,  // 二级菜单是否收缩
        	asideNone: true,  // 二级菜单是否隐藏
        	menuOneCur: "0",  // 一级菜单选中索引
        	menuTwoCur: "",  // 二级菜单选中索引
        	// 菜单数据
        	menuData: [
        		{
        			title: "首页",
        			ico: "home.png",
        			ico2: "home_cur.png",
        			page: "main.htm"
        		},
        		{
        			title: "订单管理",
        			ico: "order.png",
        			ico2: "order_cur.png",
        			children: [
        				{
                			title: "订单列表",
                			page: "/vendor/ordermain/tolist"
                		}
        			]
        		},
        		{
        			title: "商品管理",
        			ico: "product.png",
        			ico2: "product_cur.png",
        			children: [
        				{
                			title: "商品列表",
                			page: "/vendor/cater/product/tolist"
                		},
                		{
                			title: "分类管理",
                			page: "/vendor/cater/productcate/tolist"
                		}
        			]
        		},
        		{
        			title: "店铺管理",
        			ico: "vendor.png",
        			ico2: "vendor_cur.png",
        			children: [
        				{
                			title: "店铺设置",
                			page: "/vendor/vendorinfo/toUpdate"
                		},
                		{
                			title: "店铺装修",
                			page: "/vendor/vendorbasic/toSetIndex"
                		}
        			]
        		},
        		{
        			title: "优惠管理",
        			ico: "yh.png",
        			ico2: "yh_cur.png",
        			children: [
        				{
                			title: "优惠券管理",
                			page: "/vendor/cater/coupon/tolist"
                		},
                		{
                			title: "优惠设置",
                			page: "/vendor/cater/discounts/todiscounts"
                		}
        			]
        		},
        		{
        			title: "评价管理",
        			ico: "pj.png",
        			ico2: "pj_cur.png",
        			children: [
        				{
                			title: "订单评价列表",
                			page: "/vendor/cater/orderappraise/tolist"
                		}
        			]
        		},
        		{
        			title: "会员管理",
        			ico: "user.png",
        			ico2: "user_cur.png",
        			children: [
        				{
                			title: "会员列表",
                			page: "/vendor/customer/customer/tolist"
                		}
        			]
        		},
        		{
        			title: "基础数据",
        			ico: "basic.png",
        			ico2: "basic_cur.png",
        			children: [
        				{
                			title: "餐具费用",
                			page: "/vendor/vendorbasic/tosetcover"
                		},
                		{
                			title: "积分换算",
                			page: "/vendor/vendorinfo/tosetintegral"
                		},
                		{
                			title: "桌台管理",
                			page: "/vendor/dinnertable/tolist"
                		},
                		{
                			title: "规格设置",
                			page: "/vendor/vendortemplaterel/setSpec"
                		},
                		{
                			title: "员工管理",
                			page: "/vendor/vendormanager/tolist"
                		}
        			]
        		},
        		{
        			title: "系统设置",
        			ico: "xt.png",
        			ico2: "xt_cur.png",
        			children: [
        				{
                			title: "评价送积分",
                			page: "/vendor/vendorinfo/toappintegral"
                		},
                		{
                			title: "营业设置",
                			page: "/vendor/vendorinfo/toyystate"
                		},{
                			title: "外卖设置",
                			page: "/vendor/vendorbasic/tosetout"
                		},
                		{
                			title: "分享设置",
                			page: "/vendor/vendorbasic/toshareset"
                		}
        			]
        		}
        		
        	],
        	mainUrl: "main.html"  // 右侧主框架展示页面
        },
        methods: {
            dislogHide: function () {
                this.dialogFormVisible = false;
            },
            showDailog: function () {
                this.ruleform.oldPwd = "";
                this.ruleform.pwd = "";
                this.ruleform.confirmPwd = "";
                this.dialogFormVisible = true;
                this.logining = false;
            },
            updatePassword: function(){
                var self = this;
                if (self.ruleform.oldPwd == "") {
                    self.logining = true;
                    self.rules2.message = "旧密码不能为空";
                }else if(self.ruleform.pwd == "") {
                    self.logining = true;
                    self.rules2.message = "新密码不能为空";
                }else if(self.ruleform.oldPwd == self.ruleform.pwd){
                    self.logining = true;
                    self.rules2.message = "新旧密码不能相同";
                } else if (self.ruleform.confirmPwd == ""){
                    self.logining = true;
                    self.rules2.message = "确认新密码不能为空";
                } else if (self.ruleform.pwd != self.ruleform.confirmPwd) {
                    self.logining = true;
                    self.rules2.message = "两次输入的新密码不一样";
                } else {
                    $.post(
                        "/vendor/vendormanager/updatepassword",
                        {oldPwd: this.ruleform.oldPwd, pwd: this.ruleform.pwd, confirmPwd: this.ruleform.confirmPwd},
                        function (data) {
                            if (data.returnCode == "1") {
                                self.$message({
                                    message: '修改成功',
                                    type: 'success',
                                    customClass: 'message-center',
                                    duration: 1500
                                });
                                self.dialogFormVisible = false;
                            } else {
                                var message = data.returnNote;
                                if (message == "pwd_empty") {
                                    self.logining = true;
                                    self.rules2.message = "密码不能为空";
                                } else if (message == "no_manager") {
                                    window.location.href = "/tologin";
                                }else if (message == "error_pwd") {
                                    self.logining = true;
                                    self.rules2.message = "旧密码错误";
                                } else if (message == "no_equal") {
                                    self.logining = true;
                                    self.rules2.message = "两次输入的新密码不一样";
                                } else {
                                    self.logining = true;
                                    self.rules2.message = "操作失败,请联系管理员";
                                }
                            }
                        }
                    );
                }
            },
        	// 切换一级菜单显示隐藏
        	menuIcoTg() {
        		this.menuIco = !this.menuIco;
        	},
        	// 切换二级菜单收缩展开
        	asideTg() {
        		this.asideHide = !this.asideHide;
        	},
        	// 一级菜单展示二级菜单
        	menuGo(item,index) {
        		this.menuOneCur = index;
				if(!!item.page){   // 一级菜单页面跳转
					this.asideNone = true;
					this.menuIco = false;
        			this.mainUrl = item.page;
					return;
				}
        		this.menuTwoCur = "0";
        		this.asideNone = false;
        		this.menuIco = true;
				this.mainUrl = item.children[0].page;
        	},
        	// 二级菜单页面跳转
        	pageGo(url,index) {
        		this.menuTwoCur = index;
        		this.menuIco = true;
        		this.mainUrl = url;
        	},

        }
    })
</script>
</html>
